const HOST = require('../../../config.js').host

const app = getApp()

Page({

  /**
   * 页面的初始数据
   */
  data: {
    coupons: [],
  },

  /**
   * 生命周期函数--监听页面加载
   */
  onLoad: function (options) {
    this.scanCoupons();
    
  
  },


  navigateTo(e) {
    wx.navigateTo({
      url: `../../detail/detail?id=${e.currentTarget.dataset.id}`
    })
  },

  /**
   * 查看优惠券
   */
  scanCoupons()
  {
    let self = this;
    wx.request({
      url: HOST + 'v1/coupons/findByUserId/' + app.userId,
      method: 'GET',
      success(res) {
        if (res.data.sysCode === 1) {
          self.setData({
            coupons: res.data.data,
          })
        }
      }
    })
  }
})